<?php

namespace App\Http\Controllers\Common;

use App\Models\Comment;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Notifications\DatabaseNotification;

class NotificationController extends Controller
{
    //创建一个读取通知的方法
    public function read(DatabaseNotification $notification){
        //设置通知为已读状态
        $notification->markAsRead();
        $comment = Comment::find($notification->data['comment_id']);
        return redirect($comment->relationModel->link(['comment_id'=>$comment['id']]));
    }
}
